home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 9 code / Tracks / TraceModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-16  |  5.3 KB  |  147 lines  |  [TEXT/MPS ]

  1. #ifndef __TRACEMODULE__
  2. #define __TRACEMODULE__
  3.  
  4. #include <Types.h>
  5. #include <Files.h>
  6. #include <Devices.h>
  7.  
  8. #include "Tracks.h"
  9.  
  10. typedef signed char cnum;
  11. typedef signed short snum;
  12. typedef signed long lnum;
  13. typedef unsigned char chex;
  14. typedef unsigned short shex;
  15. typedef unsigned long lhex;
  16.  
  17. // Preference file type... 
  18. #define kPrefsOSType    'pref'
  19.  
  20.  
  21. // These two lines will be moved to a resource file... 
  22. #define kInstallTrace 20        // csCode for target drivers Install Trace request
  23. #define kRemoveTrace 21            // csCode for target drivers Remove Trace request
  24.  
  25.  
  26. // These are resource types/ID for the prefrence file, for the name 
  27. //    of the target driver (ie .ASNA, in resource kDRp in their pref file..)
  28. #define kDrvrNameResType    'kDRp'
  29. #define kDrvrNameResID        128        
  30.  
  31. #define kStackCopyLength  24
  32.  
  33. void StackPeek(short level, Ptr *procNamePtrLoc, short *procNameLenLoc,
  34.     Ptr *callbyNamePtrLoc, short *callbyNameLenLoc, Ptr *stackPtrLoc);
  35. pascal Boolean UTLock(Boolean *flag);
  36.  
  37. typedef struct
  38.     {
  39.     OSType fCheckID;            // 'TRAC' for finding this block in memory
  40.     OSType fMyCreator;            // Used when creating a trace file
  41.     OSType fMyFileType;            // Used when creating a trace file
  42.     lhex fTraceBuffSize;        // Size of the trace buffer
  43.  
  44.     snum fTraceBuffSizeIndex;    // Keeps track of which of several possible buffer sizes
  45.  
  46.       Ptr fBuffStartPtr;            // Points to start of buffer
  47.       Ptr fBuffEndPtr;            // Points to last byte of buffer
  48.     Ptr    fNextReadPtr;            // Points to start of next read
  49.     Ptr fNextWritePtr;            // Points to start of next write
  50.     MaskType fTraceMask;        // The trace mask data a lhex[4]
  51.     MaskType fBreakMask;        // ditto for breakmask...
  52.  
  53.     Boolean    fTraceLock;            // Locks out interrupting tracing requests
  54.     Boolean fBufferEnabled;        // True when trace buffer allocated
  55.     Boolean fTraceOnline;        // True when online (tracing)
  56.     Boolean fFileEnabled;        // True when trace file is enabled
  57.     Boolean fAutomaticWrite;    // True if trace file written automatically
  58.     Boolean fLockedOutFlag;        // True if tracing request was locked out
  59.     shex fMaxRecordSize;        // Maximum size trace record allowed
  60.     snum fFileRefNum;            // Trace File refNum
  61.     snum fVRefNum;                // Trace File vRefNum (volume)
  62.     lhex fBytesWritten;            // Running count of bytes written to file
  63.     snum fWriteErr;                // Set if write error occurred
  64.     snum fDriversRefNum;        // Refnum of the target driver
  65.     chex fTimeStampType;        // 1=DateTime, 2=TickCount
  66.     Boolean fFileIsOpen;        // True when trace file open
  67.     char fTraceFileName[32];    // 31 bytes max Pascal string
  68.     char fDriverPStrName[32];    // The .DrvrName, as a pascal string...  (.ASNA)
  69.     Boolean    fDebugMarkUnset;        // If set, will do _Debugger before returning to target driver...
  70.     Boolean    fBreakOnceThenClear; // If set, breakpoint will clear upon its encounter
  71.     Boolean    fTraceOnStartup;    // Shows if it should break on status... this
  72.                                 // is read from a pref file and if true, inserted
  73.                                 // here so it can be reproduced at next startup...
  74. } TraceGlobals;
  75.  
  76. typedef struct
  77. {
  78.     short length;
  79.     char diagID;
  80.     char partCode;
  81.     unsigned long timeStamp;
  82.     char timeStampType;
  83.     char formatID;
  84. } NewRecordTemplate;
  85.  
  86. // This is used like by BlockAppend calls. 
  87. typedef struct 
  88. {
  89.     chex    *Begin, *End;
  90.     chex    *Mark;
  91. } SafeMemBlock;
  92.  
  93. // These are from Tim Enwall's iacDriver in develop
  94. // New driver interface to be called by DriverGlue.a
  95. #ifdef USEPASCAL
  96. pascal OSErr TControl(CntrlParam *ctlPB, DCtlPtr dCtl);
  97. pascal OSErr TClose(CntrlParam *ctlPB, DCtlPtr dCtl);
  98. pascal OSErr TOpen(CntrlParam *ctlPB, DCtlPtr dCtl);
  99. pascal OSErr TPrime(CntrlParam *ctlPB, DCtlPtr dCtl);
  100. pascal OSErr TStatus(CntrlParam *ctlPB, DCtlPtr dCtl);
  101. #else
  102.  
  103. OSErr TControl(CntrlParam *ctlPB, DCtlPtr dCtl);
  104. OSErr TClose(CntrlParam *ctlPB, DCtlPtr dCtl);
  105. OSErr TOpen(CntrlParam *ctlPB, DCtlPtr dCtl);
  106. OSErr TPrime(CntrlParam *ctlPB, DCtlPtr dCtl);
  107. OSErr TStatus(CntrlParam *ctlPB, DCtlPtr dCtl);
  108.  
  109. #endif
  110.  
  111. /* Trace code external interface */
  112. pascal void TraceProc(long refcon, char diagID, char partCode, 
  113.     char formatID, long data1, long data2, long data3);
  114.  
  115. pascal short TraceEntry(TraceGlobals *globals, short csCode, TraceParamBlock *paramPtr, DCtlPtr dCtl);
  116.  
  117. /* Internal use only */
  118. snum CloseTraceFile(TraceGlobals *globals);
  119. snum DisableTraceBuffer(TraceGlobals *globals);
  120. snum DisableTraceFile(TraceGlobals *globals);
  121. snum EnableTraceBuffer(TraceGlobals *globals, TraceParamBlock *paramPtr);
  122. snum SetTraceFileName(TraceGlobals *globals, TraceParamBlock *paramPtr);
  123. snum GetBufferSpace(TraceGlobals *globals, shex amountOfSpace, Boolean *dataLost);
  124. void GetNewRecord(TraceGlobals *globals, shex recordSize, Ptr *recordAddr, 
  125.  shex *splitSize, Ptr *secondAddr);
  126. snum GetTraceProc(TraceGlobals *globals, TraceParamBlock *paramPtr);
  127. snum GetTraceStatus(TraceGlobals *globals, TraceParamBlock *paramPtr);
  128. void InitTrace(TraceGlobals *globals);
  129. snum OpenTraceFile(TraceGlobals *globals);
  130. snum ReadTrace(TraceGlobals *globals, TraceParamBlock *paramPtr);
  131. snum ResetTrace(TraceGlobals *globals);
  132. snum SetTraceOffline(TraceGlobals *globals);
  133. snum SetTraceOnline(TraceGlobals *globals, char *drvrName);
  134. snum WriteTraceBuffer(TraceGlobals *globals);
  135.  
  136.  
  137. snum SendMaskToCdev(TraceGlobals *globals, TraceParamBlock *paramPtr,short csCode);
  138. snum GetMaskFromCDEV(TraceGlobals *globals, TraceParamBlock *paramPtr,short csCode);
  139. snum ResetEOF(TraceGlobals *globals);
  140. snum ClearTraceBuffer(TraceGlobals *globals);
  141. snum ShowGlobals(TraceGlobals *globals);
  142. void DoCopyMask(MaskType src,MaskType dst);
  143. #endif
  144.  
  145.  
  146.  
  147.